| XmlSearch |
|
 |
| Description
|
|
Uses an XPath language expression to search an XML document that is represented as a string variable.
|
| |
| Returns
|
|
An array of XML object nodes that match the search criteria.
|
| |
| Category
|
|
Extensibility functions, XML functions
|
| |
| Function syntax |
XmlSearch(xmlDoc, xPathString)
|
| |
| See also
|
|
cfxml, IsXmlDoc, XmlChildPos, XmlChildPos, XmlFormat, XmlNew, XmlParse, XmlTransform
|
| |
| History
|
|
ColdFusion MX: Added this function.
|
| |
| Parameters
|
| |
| Parameter |
Description |
| xmlDoc |
XML document object |
| xPathString |
XPath expression |
|
| |
| Usage
|
|
XPath is specified by the World-Wide Web Consortium. For detailed information on XPath, see the W3C website at www.w3.org/TR/xpath.
|
| |
| Example
|
The following example extracts the elements named last, which contain employee last names, from the employeesimple.xml file, and displays the names.
<cffile action="read"
file="C:\inetpub\wwwroot\examples\employeesimple.xml"
variable="myxml">
<cfscript>
myxmldoc = XmlParse(myxml);
selectedElements = XmlSearch(myxmldoc, "/employee/name/last");
for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1)
writeoutput(selectedElements[i].XmlText & "<br>");
</cfscript>
|